import path from 'path';
import typescript from "rollup-plugin-typescript2";
import babel from "rollup-plugin-babel";
import tslint from "rollup-plugin-tslint";
import { terser } from "rollup-plugin-terser";
import resolve from "rollup-plugin-node-resolve";
import clear from "rollup-plugin-clear";


const resolvePath = (pathname) => path.resolve(__dirname, pathname);

const config = {
    output: resolvePath('dist'),
}

export default {
    input: './src/index.tsx', // 输入路径
    output: { // 输出文件以及输出文件格式
        dir: config.output,
        format: 'es',
        sourceMap: true,
        entryFileNames: '[name].js',
        exports: 'named'
    },
    experimentalCodeSplitting: true,
    plugins: [
        clear({
            targets: [config.output]
        }),
        resolve(),
        tslint(), 
        typescript(),
        babel(),
        terser({ compress: { drop_console: true } }),
    ],
    external: ['react', 'react-router-dom'], // 不需要的模块剔除，减小打包的体积
}